import instance from "@/api/axiosConfig";
import urls from '../urls'
const { engine } = urls

// 所有搜索引擎
export function getEngineList(params:any) {
    return instance({
        url: engine.list,
        method: "get",
    });
}

// 添加搜索引擎
export function addEngine(data:any) {
    return instance({
        url: engine.add,
        method: "post",
        data: data,
    });
}

// 更新搜索引擎
export function updateEngine(data:any) {
    return instance({
        url: engine.update,
        method: "put",
        data,
    });
}

// 删除搜索引擎
export function destroyEngine(params:any) {
    return instance({
        url: engine.destroy,
        method: "delete",
        params: params,
    });
}

export async function fetchUserEngine(params: any) {
    // return instance.get("/api/extension/engines", {
    //     params: params
    // });

    return fetch('http://localhost:5600/mock-json/engines.json').then(res => {
        if (!res.ok) {
            throw new Error(`请求失败`)
        }
        return res.json()
    })
}


